<template>
	<view class="">
		<fa-navbar title="入会申请"></fa-navbar>
		<view class="list">
			<view class="item" v-for="(v,i) in list" :key="i">
				<view class="left">
					{{v.title}}
				</view>
				<view class="right">
					{{v.value}}

				</view>
			</view>
			<view class="item">
				<view class="left">
					营业执照
				</view>
				<view class="right">
					<view class="preview" @click="previewImage">
						查看
					</view>
				</view>
			</view>
		</view>
		<view class="edit" @click="edit">
			我要修改
		</view>
		<view class="submit" @click="submit">
			确认提交
		</view>
		<u-popup v-model="show" mode="center" width="520rpx" height="420rpx" border-radius="20">
			<view class="image">
				<image src="/static/images/success.jpg" mode=""
					style="width: 250rpx;height: 160rpx;border-radius: 50%;margin-left: 142rpx; margin-top: 30rpx;">
				</image>
				<view class="" style="font-size: 34rpx;color: #666;text-align: center;margin-top: 20rpx;">
					提交成功，请等待审核。
				</view>
				<view class="" @click='confirm'
					style="	width: 248rpx;height: 74rpx;background-color: #d9001b;border-radius: 37rpx;text-align: center;line-height: 74rpx;color: #fff;margin: 50rpx auto;">
					我知道了
				</view>
			</view>
		</u-popup>

		<view class="" style="height: 30rpx;">

		</view>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				businessLicense: '',
				img: '',
				show: false,
				list: [{
						title: '姓名',
						value: '吴晓野',

					},
					{
						title: '性别',
						value: '福建省福州市台江区宁化街道IFC福州国际金融中心xxxxx门牌号',

					},
					{
						title: '民族',
						value: '',

					},
					{
						title: '籍贯',
						value: '',

					},
					{
						title: '出生年月',
						value: '',

					},
					{
						title: '政治面貌',
						value: '',

					},
					{
						title: '身份证号码',
						value: '',

					},
					{
						title: '手机号码',
						value: '',

					},
					{
						title: '社会职务',
						value: '',

					},
					{
						title: '所属企业及职务',
						value: '福建省福州市台江区宁化街道IFC福州国际金融中心xxxxx门牌号',

					},
					{
						title: '统一社会信用号',
						value: '',

					}, {
						title: '企业类型',
						value: '',

					}, {
						title: '企业行业分类',
						value: '',

					},
					{
						title: '企业注册地',
						value: '',

					}, {
						title: '企业所在地址',
						value: '',

					}, {
						title: '销售总额(万元)',
						value: '',

					},
					{
						title: '员工总数(人)',
						value: '',

					}, {
						title: '企业联络员',
						value: '',

					},
					{
						title: '联络员电话',
						value: '',

					},
					{
						title: '企业简介',
						value: '',

					},
				]
			}
		},
		created() {
			const form1 = uni.getStorageSync('firstForm')
			const form2 = uni.getStorageSync('secondForm')
			const image = uni.getStorageSync('image')
			this.businessLicense = this.$u.http.config.baseUrl + image
			this.img = image
			// 合并 form1 和 form2，过滤掉 title 为 '手机短信验证码' 的对象
			const mergedForm = form1
				.map(item => ({
					title: item.title,
					value: item.value
				}))
				.concat(
					form2.map(item => ({
						title: item.title,
						value: item.value
					}))
				)
				.filter(item => item.title !== '手机短信验证码');

			// 将合并后的数据存入组件的数据对象中
			console.log(mergedForm, 'mergedForm');
			this.list = mergedForm;


		},
		methods: {
			confirm() {
				this.$u.route('/pages/my/membership', {
					status: 2
				});
			},
			previewImage() {
				uni.previewImage({
					urls: [this.businessLicense] // 在数组中传入图片路径字符串数据
				});
			},
			edit() {
				this.$u.route('/pages/applicationForm/applicationForm');
			},
			async submit() {

				let data = {
					name: this.list[0].value,
					sex: this.list[1].value,
					nation: this.list[2].value,
					native: this.list[3].value,
					birthday: this.list[4].value,
					political_outlook: this.list[5].value,
					education: this.list[6].value,
					idcard: this.list[7].value,
					mobile: this.list[8].value,
					code: '123', //短信验证码
					position: this.list[9].value,
					unit: this.list[10].value,
					qy_type: this.list[11].value,
					hy_type: this.list[12].value,
					brnumber: this.list[13].value,
					register_address: this.list[14].value,
					qy_address: this.list[15].value,
					total_sales: this.list[16].value,
					employee: this.list[17].value,
					qy_person: this.list[18].value,
					qy_phone: this.list[19].value,
					qy_introduct: this.list[20].value,
					license: this.img

				}
				let res = await this.$api.add_info(data);
				if (!res.code) {
					uni.showModal({
						title: '友情提示',
						content: res.msg,
						showCancel: false,
						// success: (res) => {
						// 	if (res.confirm) {
						// 		this.$u.route('/pages/applicationForm/applicationForm');
						// 	}
						// }
					})
					return;
				}
				this.show = true


			}
		},
	}
</script>

<style scoped lang="scss">
	.list {
		padding: 0rpx 35rpx;
		font-size: 30rpx;


		.item {

			padding: 35rpx 0rpx;
			border-bottom: 3rpx solid #ececec;
			display: flex;

			.left {
				width: 240rpx;
			}

			.right {
				flex: 1;

				.preview {
					width: 95rpx;
					height: 49rpx;
					background-color: #fff;
					border-radius: 7rpx;
					border: solid 1rpx #d9001b;
					color: #d9001b;
					text-align: center;
					line-height: 49rpx;
					font-size: 24rpx
				}

			}

		}


	}

	.edit {
		width: 650rpx;
		height: 67rpx;
		background-color: #fff;
		border-radius: 10rpx;
		color: #d9001b;
		text-align: center;
		border: solid 1rpx #d9001b;

		line-height: 67rpx;
		font-size: 26rpx;
		margin: 0rpx auto;
	}

	.submit {
		width: 650rpx;
		height: 67rpx;
		background-color: #d9001b;
		border-radius: 10rpx;
		color: #fff;
		text-align: center;
		line-height: 67rpx;
		font-size: 26rpx;
		margin: 30rpx auto;
	}
</style>